<?php
declare(strict_types=1);

namespace app\admin\model;

use think\Model;

/**
 * 部分发货申请表模型
 * Class OrderPartDeliveryApply
 * @package app\admin\model
 */
class OrderPartDeliveryApply extends BaseModel
{
    // 定义数据表名
    protected $name = 'order_part_delivery_apply';

    // 定义主键
    protected $primaryKey = 'id';

    // 定义创建时间字段名
    protected $createTime = 'create_time';

    // 定义更新时间字段名
    protected $updateTime = 'update_time';

    // 定义自动时间戳
    protected $autoWriteTimestamp = true;

    // 设置字段信息
    protected $schema = [
        'id'          => 'int',
        'order_id'    => 'int',
        'remark'      => 'string',
        'status'      => 'int',
        'creator'     => 'int',
        'create_time' => 'datetime',
        'updater'     => 'int',
        'update_time' => 'datetime',
        'is_del'      => 'int'
    ];

    protected $attributes = [
        'status' => [
            1 => '待审核',
            2 => '已审核'
        ]
    ];

    /**
     * 关联申请项
     */
    public function items()
    {
        return $this->hasMany(OrderPartDeliveryApplyItem::class, 'order_part_delivery_apply_id', 'id');
    }
}
